clear

use pitchers

gen before=0
replace before=1 if season==2012

gen after=0
replace after=1 if season==2013

gen inter=after*treatment

gen age=season-birth
gen age2=age*age

gen fa_m1=0
replace fa_m1=1 if season==begin-1

gen fa_m2=0
replace fa_m2=1 if season==begin-2

gen fa_m3=0
replace fa_m3=1 if season==begin-3

gen fa_p1=0
replace fa_p1=1 if season==begin

gen fa_p2=0
replace fa_p2=1 if season==begin+1

gen fa_p3=0
replace fa_p3=1 if season==begin+2

gen size=money/duration
gen logsize=log(size)


xtset id season

drop if id==20 | id==24
drop if begin<2011

sum ip era age size fa_m1 treatment
sum ip era age size fa_m1 treatment if season==2012
sum ip era age size fa_m1 treatment if season==2013


xtreg ip inter after fa_m1 al, fe
xtreg era inter after fa_m1 al if ip>=20, fe
xtreg ip inter treatment after fa_m1 al age age2 logsize, re
xtreg era inter treatment after fa_m1 al age age2 logsize if ip>=20, re
